<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客发布</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css">
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css">
</head>
<style>
    body {
        background: #fafafa;
        background-attachment: fixed !important;
        background-size: cover !important;
    }
</style>
<body>
<!--导航-->
<nav th:replace="admin/_fragments :: menu(1)" class="ui top fixed menu">
    <!--流动导航组件-->
    <div class="m-container">
        <div class="ui secondary stackable menu">
            <div class="item">
                <h2 class="ui header">Ended</h2>
            </div>&nbsp;
            <div class="ui dropdown item m-item m-mobile-hide" th:classappend="${n==1} ? 'active'">
                <div class="text">
                    <i class="anchor icon"></i>博客管理
                </div>
                <div class="menu">
                    <a href="#" th:href="@{/admin/blogs}" class="item">博客列表</a>
                    <a href="#" th:href="@{/admin/blogs/input}" class="item">博客发布</a>
                </div>
            </div>
            <div class="ui dropdown item m-item m-mobile-hide" th:classappend="${n==2} ? 'active'">
                <div class="text">
                    <i class="idea icon"></i>分类管理
                </div>
                <div class="menu">
                    <a href="#" th:href="@{/admin/types}" class="item">分类列表</a>
                    <a href="#" th:href="@{/admin/types/input}" class="item">新增分类</a>
                </div>
            </div>
            <div class="ui dropdown item m-item m-mobile-hide" th:classappend="${n==3} ? 'active'">
                <div class="text">
                    <i class="idea icon"></i>标签管理
                </div>
                <div class="menu">
                    <a href="#" th:href="@{/admin/types}" class="item">标签列表</a>
                    <a href="#" th:href="@{/admin/types/input}" class="item">新增标签</a>
                </div>
            </div>
            <a href="#" th:href="@{/admin/message}" class="m-item item m-mobile-hide" th:classappend="${n==4} ? 'active'">
                <i class="comment alternate icon"></i>留言管理</a>
            <a href="#" th:href="@{/admin/about}" class="m-item item m-mobile-hide" th:classappend="${n==5} ? 'active'">
                <i class="info icon"></i>博主信息</a>
            <div class="m-item item m-mobile-hide">
                <a class="ui basic vertical animated circular button" href="#" target="_blank" th:href="@{/admin/logout}"
                   tabindex="0">
                    <div class="hidden content">注销</div>
                    <div class="visible content">
                        <i class="cloud icon"></i>
                    </div>
                </a>
            </div>
        </div>
    </div>
    <a href="#" class="ui menu toggle basic icon button m-top-right m-mobile-show m-bg">
        <i class="sidebar icon"></i>
    </a>
</nav>


<!--中间内容-->
<div class="m-padded-tb-max m-container-large">
    <div class="ui container">
        <form id="blog-form" action="#" th:object="${blog}" th:action="@{/admin/blogs}" method="post" class="ui form">
            <input type="hidden" name="published" th:value="*{published}">
            <input type="hidden" name="id" th:value="*{id}">
            <!--title-->
            <div class="required field">
                <div class="ui left labeled input">
                    <div class="ui selection compact blue basic dropdown label">
                        <input type="hidden" value="原创" name="flag" th:value="*{flag}">
                        <i class="dropdown icon"></i>
                        <div class="text">原创</div>
                        <div class="menu">
                            <div class="item" data-value="原创">原创</div>
                            <div class="item" data-value="转载">转载</div>
                            <div class="item" data-value="翻译">翻译</div>
                        </div>
                    </div>
                    <!--Title-->
                    <input type="text" name="title" placeholder="标题" th:value="*{title}">
                </div>
            </div>
            <!--博客content-->
            <div class="required field">
                <!--z-index表示叠放层次-->
                <div id="md-content" style="z-index: 9999 !important;">
                    <textarea placeholder="博客内容" name="content" style="display: none" th:text="*{content}">
                        MarkDown
                    </textarea>
                </div>
            </div>
            <!---->
            <div class="two fields">
                <!--分类-->
                <div class="required field">
                    <div class="ui left labeled action input">
                        <label class="ui compact blue basic label">分类</label>
                        <div class="ui fluid selection dropdown">
                            <input type="hidden" name="type.id" th:value="*{type}!=null ? *{type.id}">
                            <i class="dropdown icon"></i>
                            <div class="default text">分类</div>
                            <div class="menu">
                                <div th:each="type : ${types}" class="item" data-value="1"
                                     th:data-value="${type.id}" th:text="${type.name}">算法清单</div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--标签-->
                <div class="field">
                    <div class="ui left labeled action input">
                        <label class="ui compact blue basic label">标签</label>
                        <div class="ui fluid multiple search selection dropdown">
                            <input type="hidden" name="tagIds" th:value="*{tagIds}">
                            <i class="dropdown icon"></i>
                            <div class="default text">标签</div>
                            <div class="menu">
                                <div th:each="tag : ${tags}" class="item" data-value="1"
                                     th:data-value="${tag.id}" th:text="${tag.name}">MySQL</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--首图引用地址-->
            <div class="required field">
                <div class="ui left labeled input">
                    <label class="ui blue basic label">首图</label>
                    <input type="text" name="firstPicture" th:value="*{firstPicture}" placeholder="首图引用地址">
                </div>
            </div>
            <!--博客描述-->
            <div class="field">
                <textarea name="description" th:text="*{description}" placeholder="博客描述..." maxlength="200"></textarea>
            </div>
            <!--功能-->
            <div class="inline fields">
                <!--推荐-->
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="recommend" name="recommend" checked th:checked="*{recommend}" class="hidden">
                        <label for="recommend">推荐</label>
                    </div>
                </div>
                <!--置顶-->
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="sticky" name="sticky" th:checked="*{sticky}" class="hidden">
                        <label for="sticky">置顶</label>
                    </div>
                </div>
                <!--转载-->
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="shareStatement" name="shareStatement" th:checked="*{shareStatement}" class="hidden">
                        <label for="shareStatement">转载声明</label>
                    </div>
                </div>
                <!--赞赏-->
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="appreciation" name="appreciation" th:checked="*{appreciation}" class="hidden">
                        <label for="appreciation">赞赏</label>
                    </div>
                </div>
                <!--评论-->
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="commentabled" name="commentabled" th:checked="*{commentabled}" class="hidden">
                        <label for="commentabled">评论</label>
                    </div>
                </div>
            </div>
            <!--错误提示-->
            <div class="ui error message"></div>
            <div class="ui right aligned container">
                <!--点击按钮，返回一个响应事件onclick="window.history.go(-1)"返回上一个页面-->
                <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button type="button" id="save-btn" class="ui secondary button">保存</button>
                <button type="button" id="publish-btn" class="ui blue button">发布</button>
            </div>
        </form>
    </div>
</div>

<!--底部footer-->
<footer th:replace="admin/_fragments :: footer" class="ui m-bg segment m-padded-tb-huge">
    <div class="ui center aligned container">
        <div class="ui divided stackable grid"> <!--布局会分成16份-->
            <div class="four wide column">
                <img src="../../static/images/plug/WeChat.PNG" alt="WeChatQR Code" class="ui centered rounded image"
                     style="width: 110px">
            </div>
            <div class="four wide column">
                <h4 class="ui header m-opacity-small">博客简介</h4>
                <p class="m-text-thin m-text-spaced m-opacity-small">
                    创建此博客是为了提供一个平台来供自己分享生活、自己的所见所闻所感、以及分享学习心得和资源......
                </p>
            </div>
            <div class="four wide column">
                <h4 class="ui header m-opacity-small">联系我</h4>
                <div class="ui link list ">
                    <a href="#" class="item">QQ：3320014521</a>
                    <a href="#" class="item">e-mail：woshihauhuaa@outlook.com</a>
                </div>
            </div>
            <div class="four wide column">
                <div class="three wide column">
                    <br>
                    <br>
                    <p class="m-text-thin m-text-spaced">
                        愿你编码半生，归来仍是少年......
                    </p>
                </div>
            </div>
        </div>
        <div class="ui inverted section divider"></div>
        <p class="m-text-thin m-opacity-mini">Copyright © 2020-2021 YanYunHua Designed by YanYunHua</p>
    </div>
</footer>


<!--/*/<th:block th:replace="admin/_fragments :: script">/*/-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<script src="../../static/lib/editormd/editormd.min.js"></script>
<!--<script src="../../static/js/uploadImg.js"></script>-->
<!--/*/</th:block>/*/-->

<!--导航的手机端按钮的响应页面-->
<script inline="javascript">

    //初始化Markdown编辑器
    var contentEditor;
    $(function() {
        contentEditor = editormd({
            id      : "md-content",
            width   : "100%",
            height  : 640,
            path : "/lib/editormd/lib/",
            syncScrolling: "single",
            emoji: true,
            // saveHTMLToTextarea: true,
            // tocDropdown: true,
            imageUpload : true,
            imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
            imageUploadURL : "/img/imgUpLoad",
            // onload : function() {
            //     console.log('onload', this);
                //this.fullscreen();
                //this.unwatch();
                //this.watch().fullscreen();

                //this.setMarkdown("#PHP");
                //this.width("100%");
                //this.height(480);
                //this.resize("100%", 640);
            // }
        });
    });

    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide')
    });

    $('.ui.dropdown').dropdown({
        on : 'hover'
    });

    // 保存
    $('#save-btn').click(function () {
        $('[name = "published"]').val(false);
        $('#blog-form').submit();
    })

    // 发布
    $('#publish-btn').click(function () {
        $('[name = "published"]').val(true);
        $('#blog-form').submit()
    })
    $('.ui.form').form({
        fields : {
            title : {
                identifier : 'title',
                rules : [{
                    type : 'empty',
                    prompt : '{name} : 请输入博客标题'
                }]
            },
            content : {
                identifier: 'content',
                rules: [{
                    type : 'empty',
                    prompt: '{name} : 请输入博客内容'
                }]
            },
            typeId : {
                identifier: 'type.id',
                rules: [{
                    type : 'empty',
                    prompt: '{name} : 请输入博客分类'
                }]
            },
            firstPicture : {
                identifier: 'firstPicture',
                rules: [{
                    type : 'empty',
                    prompt: '{name} : 请输入博客首图'
                }]
            }
        }
    });
</script>

</body>
</html>